

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"

#include "rtos_queues.h"
#include "driverI2C_ISR.h"
#include "driverSD_SPI_DMA_ISR_TASK.h"
#include "commands.h"

QueueHandle_t	queGpsRx,
			queGpsTx,
			//_qI2C,
			queRemoteCommands,
            queESCCommands,
            queI2C,
            queSD,
            queBtLog;

SemaphoreHandle_t semSDTX,
                  semI2C,
                  semESCBus,
                  semStability,
                    semRnTxBus,
    semRnTxDMA,
    semRnTxConfirm,
    semESCPulse;

void queuesCreate()
{
    semSDTX          = xSemaphoreCreateBinary();
    semI2C           = xSemaphoreCreateBinary();
    semESCBus           = xSemaphoreCreateBinary();
    semESCPulse           = xSemaphoreCreateBinary();
    semStability        = xSemaphoreCreateBinary();
    semRnTxBus        = xSemaphoreCreateBinary();
    semRnTxDMA        = xSemaphoreCreateBinary();
    semRnTxConfirm  = xSemaphoreCreateBinary();
    
    queGpsTx		= xQueueCreate(128,sizeof(BYTE)); //136 bytes: 8 bytes overhead
    queGpsRx		= xQueueCreate(256,sizeof(BYTE));
    queI2C          = xQueueCreate(4,sizeof(struct i2cAction_t *));
    queBtLog          = xQueueCreate(1,sizeof(struct btLogSend_t));
    queSD           = xQueueCreate(4,sizeof(struct SdCommand_t));
    queESCCommands	= xQueueCreate(8,sizeof(struct CommandIn_t));
    queRemoteCommands	= xQueueCreate(8,sizeof(struct CommandIn_t));

    // used for debugging
    if (queRemoteCommands == 0)
    {
        while(1)
        {
            portNOP();
        }
    }
}
